<include file="Common/head" />
<link rel="stylesheet" href="__PUBLIC__/css/weixin/iconfont.css">
<div class="mui-content mui-scroll-wrapper bg-white">
    <div class="mui-scroll">

        <ul class="consult-list">
            <li class="input-box"><input id="title" name="title" value="" type="text" placeholder="请输入标题" /></li>
            <li class="input-box"><input  type="text" value="{$_SESSION['userName']}" placeholder="" /></li>
            <li class="input-box">
                <textarea id="content" name="content" rows="" cols="" placeholder="请描述您的咨询问题"></textarea>
            </li>
        </ul>

        <div class="btn-box">
            <button id="sendBtn" class="mui-btn mui-btn-block send-btn" type="button">提交</button>
            <div class="text">
                <a href="{:U('WeiXin/Consult/index')}">往期咨询 <i class="iconfont icon-zuojiantou"></i></a>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">


    (function($) {
        $.init();
        document.getElementById("sendBtn").addEventListener('tap', function() {
            doSave();
        });
    })(mui);
    //mui.init();

    mui('.mui-scroll-wrapper').scroll({
        deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });

    mui.plusReady(function() {

    })

    function doSave() {
        var title = $('#title').val();
        var content = $('#content').val();
        if (!title) {
            mui.toast("请输入标题");
            return false;
        }
        if (!content) {
            mui.toast("请描述您的咨询问题");
            return false;
        }
        mui.ajax(apiUrl+'/Consulting/doAdd',{
            data:{
                title: title,
                content: content
            },
            dataType: 'json',//服务器返回json格式数据
            type: 'post',//HTTP请求类型
            success: function(cbData){
                mui.toast(cbData.msg,{duration:'long'});
                setTimeout(function () {
                    location.href = "{:U('WeiXin/Consult/index')}";
                },3000)
            }
        });
    }
</script>
<include file="Common/footer" />